import React, { Component } from "react";

class Child1 extends Component {
  // 类组件的props的默认值
  // static defaultProps = {
  //   count: 10,
  // };

  render() {
    const { msg, count } = this.props;
    return (
      <div>
        child1 - {msg} - {count}
      </div>
    );
  }
}
// static静态属性相当于直接挂载在类上面
Child1.defaultProps = {
  count: 10,
};

const Child2 = ({ msg, count }) => {
  return (
    <div>
      child2 - {msg} - {count}
    </div>
  );
};
// 对于函数组件，只能在组件上面直接挂载defaultProps
Child2.defaultProps = {
  count: 10,
};

class App extends Component {
  render() {
    return (
      <>
        <h3>props</h3>
        <Child1 msg="hello" />
        <Child2 msg="hello2" />
      </>
    );
  }
}

export default App;
